<?php
/**
 * {MainMenu.php}
 *
 * Author: asuslx (asuslx@gmail.com)
 * Date: 9/17/12
 */
 
class Component_MainMenu extends F_App_Component {

    private $_items;

    public function load($items) {

        foreach($items as $caption => $path) {
            $this->_items[] = array(
                'caption' => $caption,
                'url' => $path,
                'active' => false
            );
        }
    }

    protected function _run() {

        $path = F_App::instance()->getCallInfo()->getRequest()->getPath();

        foreach($this->_items as &$item) {

            $_1 = explode('/', $item['url']);
            $_2 = explode('/', $path);
            if($_1[1] == $_2[1]) $item['active'] = true;
        }
        $this->_assign('items', $this->_items);
    }

}